<script setup>
import { artGetChannelsService } from '@/api/article'
import { ref } from 'vue'
defineProps({
  modelValue: {
    type: [Number, String]
  },
  width: {
    type: String
  }
})
const emit = defineEmits(['update:modelValue'])
// 得到分类列表
const channelList = ref([])
const getchannelList = async () => {
  const res = await artGetChannelsService()
  channelList.value = res.data.data
  // console.log(data)
}
getchannelList()
</script>
<template>
  <el-select
    :style="{ width }"
    :modelValue="modelValue"
    @update:modelValue="emit('update:modelValue', $event)"
  >
    <!-- lable 是展示给用户看的, value 是收集起来提交给后台的  -->
    <el-option
      v-for="item in channelList"
      :key="item.id"
      :label="item.cate_name"
      :value="item.id"
    ></el-option>
    <!-- <el-option label="体育" value="222"></el-option> -->
  </el-select>
</template>
